how to fully dealloc esi after working on it with an external function (x86 asm)? #158843
Replies: 4 comments
-
Thanks for posting in the GitHub Community, @DiscoZomb1e! We're happy you're here. You are more likely to get a useful response if you are posting your question in the applicable category, the New to GitHub category is solely related to conversations around getting started on using GitHub and the community for beginners of GitHub, Community on Discussions, and those new to different areas of the product alike! This question should be in the Programming Help category. I've gone ahead and moved it for you. Good luck! |
Beta Was this translation helpful? Give feedback.
-
3 1 1,2,3
section .bss section .text main:
Arrays are commonly used with loops, where a counter register is incremented to traverse through the array. However, because assembly does not include safety features like bounds checking or automatic memory management, the programmer must take care to avoid overflows or accessing invalid memory, which can lead to bugs or crashes. Despite their low-level nature, arrays in assembly are powerful and offer a high degree of control over how data is stored and manipulated, making them essential for performance-critical code, embedded systems, and operating system development. check_pure: check_pure_loop: is_power_of_2: not_power_of_2:
array_not_pure: check_magic: address_is_magic: find_unique:
|
Beta Was this translation helpful? Give feedback.
-
3 3 1 |
Beta Was this translation helpful? Give feedback.
-
3 2 section .bss section .text insert_in_set:
Recursion in assembly follows the same logical principle as in high-level languages: a function calls itself to break a problem into smaller subproblems. However, the implementation is far more manual and error-prone, requiring precise stack management.
read_loop:
read_done:
print_loop:
next_value: print_done:
When writing recursive assembly functions, every invocation must preserve the current state: registers, return address, local variables, and parameters. Failure to do so may result in corrupted stack frames or incorrect results. For example, a recursive factorial function in assembly would push the current value of n, call itself with n-1, then multiply the result upon return. It would also have to check for a base case (e.g., n == 1) and avoid excessive calls which could lead to stack overflow.
count_loop:
count_done: count_bits_in_byte:
bit_count_loop: bit_count_done: main:
Loops are a fundamental control structure in any language, and in assembly, they are constructed using conditional and unconditional jumps. Unlike for, while, or do-while in C or Python, in assembly, loop logic is manually built using labels and jump instructions like jmp, je, jne, jg, jl, etc. A typical loop will involve setting up a counter, comparing it to a limit, executing some logic, updating the counter, and jumping back to the comparison step.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Title. popping any element gives segmentation fault
Beta Was this translation helpful? Give feedback.
All reactions